﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using App2Wpf.ViewModels;

namespace App2Wpf.Views
{
    /// <summary>
    /// cardTest.xaml 的交互逻辑
    /// </summary>
    public partial class CardTest : UserControl,ICardUC
    {
        public int ID
        {
            get => (DataContext as cardTestVM).id;
            set => (DataContext as cardTestVM).id = value;
        }
        public nameip connectNameip { get; set; }
        public CardTest(nameip serverinfo)
        {
            InitializeComponent();
            this.connectNameip = serverinfo;
            DataContext = new cardTestVM(serverinfo);
        }

        public void StartWork()
        {
            (DataContext as cardTestVM).Refresh();
        }


        private void MiniWindow_MouseDown(object sender, MouseButtonEventArgs e)
        {

            (DataContext as cardTestVM).view.SendVirtualMouse((int)e.GetPosition(MiniWindow).X, (int)e.GetPosition(MiniWindow).Y, MouseState.Down, e.ChangedButton.ToString());
        }

        private void MiniWindow_MouseUp(object sender, MouseButtonEventArgs e)
        {
            (DataContext as cardTestVM).view.SendVirtualMouse((int)e.GetPosition(MiniWindow).X, (int)e.GetPosition(MiniWindow).Y, MouseState.Up, e.ChangedButton.ToString());

        }

        private void MiniWindow_MouseMove(object sender, MouseEventArgs e)
        {
            (DataContext as cardTestVM).view.SendVirtualMouse((int)e.GetPosition(MiniWindow).X, (int)e.GetPosition(MiniWindow).Y, MouseState.Move, "");

        }

        private void MiniWindow_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            (DataContext as cardTestVM).view.WPF_logic_MouseWheel(sender, e);
        }

        private void MiniWindow_KeyDown(object sender, KeyEventArgs e)
        {
            //// 方法内部  keydown 平替 keypress
            (DataContext as cardTestVM).view.WPF_logic_KeyDown(sender, e);
        }

        private void MiniWindow_KeyUp(object sender, KeyEventArgs e)
        {

        }
    }
}
